import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
var _excluded = ["userId"],
    _excluded2 = ["userId"],
    _excluded3 = ["userInfo"],
    _excluded4 = ["userId"],
    _excluded5 = ["userInfo"],
    _excluded6 = ["userId"];
import { getCurrentOrganizationId, parseParameters } from 'utils/utils';
import { CPAAS_IAM, CPAAS_PLATFORM } from 'utils/config';
import request from 'utils/request';
var currentOrganizationId = getCurrentOrganizationId();
/**
 * 请求快码
 * @param {String} lovCode 快码的code
 */

export function enumSetQueryByCode(_x) {
  return _enumSetQueryByCode.apply(this, arguments);
}
/**
 * 租户级 查询当前登录用户所拥有分配权限的角色
 * @param {!Number} organizationId 租户id
 * @param {Object} params 查询信息
 * @param {String} params.phone 手机
 * @param {String} params.email 邮箱
 * @param {String} params.realName 描述
 * @param {String} params.loginName 账号
 * @param {Number} pagination.pagination.page 分页
 * @param {Number} pagination.pagination.size 分页大小
 */

function _enumSetQueryByCode() {
  _enumSetQueryByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(lovCode) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/lovs/value"), {
              method: 'GET',
              query: {
                lovCode: lovCode
              }
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _enumSetQueryByCode.apply(this, arguments);
}

export function querySubAccountOrgList(_x2) {
  return _querySubAccountOrgList.apply(this, arguments);
}
/**
 * 查询当前登录用户所拥有 分配 全选的 角色
 * @param {!Number} currentOrganizationId 租户id
 */

function _querySubAccountOrgList() {
  _querySubAccountOrgList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            query = parseParameters(params);
            return _context2.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/users/paging"), {
              method: 'GET',
              query: query
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _querySubAccountOrgList.apply(this, arguments);
}

export function subAccountOrgRoleQueryAll(_x3) {
  return _subAccountOrgRoleQueryAll.apply(this, arguments);
}
/**
 * 创建一个新的账号
 * @param {!Number} organizationId 当前租户id
 * @param {Object} user 账号信息
 * @param {!String} user.realName 描述
 * @param {!String} user.email 邮箱
 * @param {!String} user.phone 手机号码
 * @param {!String} user.password 密码
 * @param {!String} user.anotherPassword 确认密码
 * @param {!String} user.startDateActive 有效日期从
 * @param {String} user.endDateActive 有效日期至
 * @param {String} user.locker 冻结
 * @param {Object[]} user.memberRoleList 角色信息
 * @param {Number|String} user.memberRoleList[].assignLevel 层级 快码对应的标记的 Number
 * @param {String} user.memberRoleList[].assignLevelValue 层级值 快码对应的 value
 * @param {Number} user.memberRoleList[].roleId 角色id
 */

function _subAccountOrgRoleQueryAll() {
  _subAccountOrgRoleQueryAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(payload) {
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            return _context3.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/roles/self/user-assignable-roles"), {
              method: 'GET',
              query: payload
            }));

          case 1:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _subAccountOrgRoleQueryAll.apply(this, arguments);
}

export function subAccountOrgCreateOne() {
  return _subAccountOrgCreateOne.apply(this, arguments);
}
/**
 * 查询 子账号详情
 * @param {Number} userId - 账号id
 */

function _subAccountOrgCreateOne() {
  _subAccountOrgCreateOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
    var params,
        userInfo,
        others,
        _args4 = arguments;
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
            userInfo = params.userInfo, others = _objectWithoutProperties(params, _excluded3);
            return _context4.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/users"), {
              body: userInfo,
              method: 'POST',
              query: others
            }));

          case 3:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _subAccountOrgCreateOne.apply(this, arguments);
}

export function subAccountOrgQuery() {
  return _subAccountOrgQuery.apply(this, arguments);
}
/**
 * 更新账号
 * @param {!Number} organizationId 当前租户id
 * @param {Object} user 账号信息
 * @param {!String} user.realName 描述
 * @param {!String} user.email 邮箱
 * @param {!String} user.phone 手机号码
 * @param {String} [user.password] 密码
 * @param {String} [user.anotherPassword] 确认密码
 * @param {!String} user.startDateActive 有效日期从
 * @param {String} user.endDateActive 有效日期至
 * @param {String} user.locker 冻结
 * @param {Object[]} user.memberRoleList 角色信息
 * @param {Number|String} user.memberRoleList[].assignLevel 层级 快码对应的标记的 Number
 * @param {String} user.memberRoleList[].assignLevelValue 层级值 快码对应的 value
 * @param {Number} user.memberRoleList[].roleId 角色id
 */

function _subAccountOrgQuery() {
  _subAccountOrgQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
    var params,
        userId,
        others,
        _args5 = arguments;
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
            userId = params.userId, others = _objectWithoutProperties(params, _excluded4);
            return _context5.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/users/").concat(userId, "/info"), {
              method: 'GET',
              query: others
            }));

          case 3:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _subAccountOrgQuery.apply(this, arguments);
}

export function subAccountOrgUpdateOne(_x4) {
  return _subAccountOrgUpdateOne.apply(this, arguments);
}
/**
 * 查询当前租户下的用户所拥有的角色
 * @param {!Number} currentOrganizationId 租户id
 * @param {!Number} userId 用户id
 */

function _subAccountOrgUpdateOne() {
  _subAccountOrgUpdateOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params) {
    var userInfo, others;
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            userInfo = params.userInfo, others = _objectWithoutProperties(params, _excluded5);
            return _context6.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/users"), {
              body: userInfo,
              method: 'PUT',
              query: others
            }));

          case 2:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _subAccountOrgUpdateOne.apply(this, arguments);
}

export function subAccountOrgRoleCurrent(_x5) {
  return _subAccountOrgRoleCurrent.apply(this, arguments);
}
/**
 * 查询组织
 * @param {Number} currentOrganizationId 租户id
 * @param {Object} params 其他参数
 * @return {Promise<Object>}
 */

function _subAccountOrgRoleCurrent() {
  _subAccountOrgRoleCurrent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref) {
    var userId, params, parsedParams;
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            userId = _ref.userId, params = _objectWithoutProperties(_ref, _excluded);
            parsedParams = parseParameters(params);
            return _context7.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/member-roles/user-roles/").concat(userId), {
              method: 'GET',
              query: parsedParams
            }));

          case 3:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _subAccountOrgRoleCurrent.apply(this, arguments);
}

export function queryUnitsTree(_x6) {
  return _queryUnitsTree.apply(this, arguments);
}
/**
 * 修改密码
 * @param {!Number} id - 账号 id
 * @param {!Number} organizationId - 租户id
 * @param {!Object} body
 * @param {!String} body.originalPassword - 原密码
 * @param {!String} body.password - 密码
 * @param {!String} query
 * @param {!Number} query.organizationId - 用户 租户id
 */

function _queryUnitsTree() {
  _queryUnitsTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params) {
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            return _context8.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/hrunits/tree"), {
              query: params
            }));

          case 1:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _queryUnitsTree.apply(this, arguments);
}

export function subAccountOrgUpdatePassword(_x7, _x8, _x9, _x10) {
  return _subAccountOrgUpdatePassword.apply(this, arguments);
}
/**
 * 修改密码
 * @param {Object} params 验证信息
 * @param {String} params.password 新密码
 * @param {String} params.originalPassword 旧密码
 */

function _subAccountOrgUpdatePassword() {
  _subAccountOrgUpdatePassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, organizationId, body, query) {
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            return _context9.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/users/").concat(id, "/admin-password"), {
              body: body,
              query: query,
              method: 'PUT'
            }));

          case 1:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _subAccountOrgUpdatePassword.apply(this, arguments);
}

export function subAccountOrgUpdateSelfPassword(_x11) {
  return _subAccountOrgUpdateSelfPassword.apply(this, arguments);
}
/**
 * 解锁用户
 * @param {Number} userId 用户id
 * @param {Number} organizationId 用户 租户 id
 */

function _subAccountOrgUpdateSelfPassword() {
  _subAccountOrgUpdateSelfPassword = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref2) {
    var password, originalPassword;
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            password = _ref2.password, originalPassword = _ref2.originalPassword;
            return _context10.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/users/password"), {
              method: 'PUT',
              body: {
                originalPassword: originalPassword,
                password: password
              }
            }));

          case 2:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _subAccountOrgUpdateSelfPassword.apply(this, arguments);
}

export function subAccountSiteUserUnlock(_x12, _x13) {
  return _subAccountSiteUserUnlock.apply(this, arguments);
}
/**
 * 删除角色
 * @param {Number} memberRoleList 用户角色列表
 */

function _subAccountSiteUserUnlock() {
  _subAccountSiteUserUnlock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(userId, organizationId) {
    return _regeneratorRuntime.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            return _context11.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/users/").concat(userId, "/unlocked"), {
              method: 'POST'
            }));

          case 1:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));
  return _subAccountSiteUserUnlock.apply(this, arguments);
}

export function deleteRoles(_x14) {
  return _deleteRoles.apply(this, arguments);
}
/**
 * 查询 可分配的用户组
 * @param {number} params.tenantId - 用户所属租户id
 * @param {number} params.name - 角色名
 * @param {number} params.excludeRoleIds - 新分配 角色id
 * @param {number} params.excludeUserIds - 已分配 角色id
 * @return {Promise<void>}
 */

function _deleteRoles() {
  _deleteRoles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(memberRoleList) {
    return _regeneratorRuntime.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            return _context12.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/member-roles/batch-delete"), {
              method: 'DELETE',
              body: memberRoleList
            }));

          case 1:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _deleteRoles.apply(this, arguments);
}

export function subAccountOrgGroupQueryAll(_x15) {
  return _subAccountOrgGroupQueryAll.apply(this, arguments);
}
/**
 * 查询 已分配的用户组
 * @return {Promise<void>}
 */

function _subAccountOrgGroupQueryAll() {
  _subAccountOrgGroupQueryAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(params) {
    var parsedParams;
    return _regeneratorRuntime.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            parsedParams = parseParameters(params);
            return _context13.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/").concat(parsedParams.userId, "/user-group-assigns/exclude-groups"), {
              method: 'GET',
              query: parsedParams
            }));

          case 2:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _subAccountOrgGroupQueryAll.apply(this, arguments);
}

export function subAccountOrgGroupCurrent(_x16) {
  return _subAccountOrgGroupCurrent.apply(this, arguments);
}
/**
 * 添加用户组
 * @return {Promise<void>}
 */

function _subAccountOrgGroupCurrent() {
  _subAccountOrgGroupCurrent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref3) {
    var userId, params, parsedParams;
    return _regeneratorRuntime.wrap(function _callee14$(_context14) {
      while (1) {
        switch (_context14.prev = _context14.next) {
          case 0:
            userId = _ref3.userId, params = _objectWithoutProperties(_ref3, _excluded2);
            parsedParams = parseParameters(params);
            return _context14.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/").concat(userId, "/user-group-assigns"), {
              method: 'GET',
              query: parsedParams
            }));

          case 3:
          case "end":
            return _context14.stop();
        }
      }
    }, _callee14);
  }));
  return _subAccountOrgGroupCurrent.apply(this, arguments);
}

export function addUserGroup(_x17) {
  return _addUserGroup.apply(this, arguments);
}
/**
 * 删除用户组
 * @param {object[]} memberRoleList - 删除的角色
 */

function _addUserGroup() {
  _addUserGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(params) {
    var userId, memberGroupList;
    return _regeneratorRuntime.wrap(function _callee15$(_context15) {
      while (1) {
        switch (_context15.prev = _context15.next) {
          case 0:
            userId = params.userId, memberGroupList = params.memberGroupList;
            return _context15.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/").concat(userId, "/user-group-assigns"), {
              method: 'POST',
              body: memberGroupList
            }));

          case 2:
          case "end":
            return _context15.stop();
        }
      }
    }, _callee15);
  }));
  return _addUserGroup.apply(this, arguments);
}

export function deleteUserGroup(_x18) {
  return _deleteUserGroup.apply(this, arguments);
}
/**
 * 接口字段维护 服务
 * apiFieldService
 * @date 2019-07-09
 */

/**
 * 接口 model 不能修改
 * @typedef {object} API
 * @property {number} fieldPermissionId - 主键
 * @property {number} fieldId - 字段id
 * @property {string} permissionType - 权限类型 值集
 * @property {string} permissionRule - 权限规则 值集
 * @property {string} permissionDimension - 权限维度 值集
 * @property {number} dimensionValue - 权限维度值
 */

/**
 * @description 字段权限 model 可以 查增改删
 * @typedef {Object} FIELD_PERMISSION
 * @property {number} fieldId - 主键
 * @property {string} fieldDescription - 字段描述 480
 * @property {string} fieldName - 字段名称 120
 * @property {string} fieldType - 字段类型 值集
 * @property {number} orderSeq - 排序
 * @property {number} permissionId - 接口id
 */

/**
 * @typedef {Object} Page<T>
 * @property {number} number - 分页
 * @property {number} size - 分页大小
 * @property {number} totalElements - 总数据量
 * @property {T[]} content - 数据
 */

/**
 * @typedef {Object} PageInfo
 * @property {number} page - 分页
 * @property {number} size - 分页大小
 */

/**
 * 查询接口
 * @param params
 * @return {Promise<API[]>}
 */

function _deleteUserGroup() {
  _deleteUserGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(params) {
    var userId, remoteRemoveDataSource;
    return _regeneratorRuntime.wrap(function _callee16$(_context16) {
      while (1) {
        switch (_context16.prev = _context16.next) {
          case 0:
            userId = params.userId, remoteRemoveDataSource = params.remoteRemoveDataSource;
            return _context16.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/").concat(userId, "/user-group-assigns"), {
              method: 'DELETE',
              body: remoteRemoveDataSource
            }));

          case 2:
          case "end":
            return _context16.stop();
        }
      }
    }, _callee16);
  }));
  return _deleteUserGroup.apply(this, arguments);
}

export function apiFieldApiQuery(_x19) {
  return _apiFieldApiQuery.apply(this, arguments);
}
/**
 * 查询对应接口的字段权限
 * @param {number} userId - 用户id
 * @param {number} permissionId - 接口id
 * @param {PageInfo} params - 查询分页参数
 * @param {FIELD_PERMISSION} params - 查询实体
 * @return {Promise<API[]>}
 */

function _apiFieldApiQuery() {
  _apiFieldApiQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee17$(_context17) {
      while (1) {
        switch (_context17.prev = _context17.next) {
          case 0:
            query = parseParameters(params);
            return _context17.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(getCurrentOrganizationId(), "/apis"), {
              method: 'GET',
              query: query
            }));

          case 2:
          case "end":
            return _context17.stop();
        }
      }
    }, _callee17);
  }));
  return _apiFieldApiQuery.apply(this, arguments);
}

export function apiFieldFieldPermissionQuery(_x20, _x21, _x22) {
  return _apiFieldFieldPermissionQuery.apply(this, arguments);
}
/**
 * 修改对应接口的字段权限
 * @param {number} userId - 用户id
 * @param {number} permissionId - 接口id
 * @param {FIELD_PERMISSION} record - 修改实体
 */

function _apiFieldFieldPermissionQuery() {
  _apiFieldFieldPermissionQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(userId, permissionId, params) {
    var query;
    return _regeneratorRuntime.wrap(function _callee18$(_context18) {
      while (1) {
        switch (_context18.prev = _context18.next) {
          case 0:
            query = parseParameters(params);
            return _context18.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(getCurrentOrganizationId(), "/apis/").concat(permissionId, "/user/").concat(userId), {
              method: 'GET',
              query: query
            }));

          case 2:
          case "end":
            return _context18.stop();
        }
      }
    }, _callee18);
  }));
  return _apiFieldFieldPermissionQuery.apply(this, arguments);
}

export function apiFieldFieldPermissionUpdate(_x23, _x24, _x25) {
  return _apiFieldFieldPermissionUpdate.apply(this, arguments);
}
/**
 * 新增对应接口的字段权限
 * @param {number} userId - 用户id
 * @param {number} permissionId - 接口id
 * @param {FIELD_PERMISSION} record - 修改实体
 */

function _apiFieldFieldPermissionUpdate() {
  _apiFieldFieldPermissionUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(userId, permissionId, record) {
    return _regeneratorRuntime.wrap(function _callee19$(_context19) {
      while (1) {
        switch (_context19.prev = _context19.next) {
          case 0:
            return _context19.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(getCurrentOrganizationId(), "/apis/").concat(permissionId, "/user/").concat(userId), {
              method: 'PUT',
              body: record
            }));

          case 1:
          case "end":
            return _context19.stop();
        }
      }
    }, _callee19);
  }));
  return _apiFieldFieldPermissionUpdate.apply(this, arguments);
}

export function apiFieldFieldPermissionCreate(_x26, _x27, _x28) {
  return _apiFieldFieldPermissionCreate.apply(this, arguments);
}
/**
 * 删除对应接口的字段权限
 * @param {number} permissionId - 接口id
 * @param {FIELD_PERMISSION} record - 修改实体
 */

function _apiFieldFieldPermissionCreate() {
  _apiFieldFieldPermissionCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(userId, permissionId, record) {
    return _regeneratorRuntime.wrap(function _callee20$(_context20) {
      while (1) {
        switch (_context20.prev = _context20.next) {
          case 0:
            return _context20.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(getCurrentOrganizationId(), "/apis/").concat(permissionId, "/user/").concat(userId), {
              method: 'POST',
              body: record
            }));

          case 1:
          case "end":
            return _context20.stop();
        }
      }
    }, _callee20);
  }));
  return _apiFieldFieldPermissionCreate.apply(this, arguments);
}

export function apiFieldFieldPermissionRemove(_x29, _x30) {
  return _apiFieldFieldPermissionRemove.apply(this, arguments);
}
/**
 * 查询已分配的安全组
 * @param {object} params - 查询参数
 */

function _apiFieldFieldPermissionRemove() {
  _apiFieldFieldPermissionRemove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(permissionId, record) {
    return _regeneratorRuntime.wrap(function _callee21$(_context21) {
      while (1) {
        switch (_context21.prev = _context21.next) {
          case 0:
            return _context21.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(getCurrentOrganizationId(), "/apis/").concat(permissionId, "/permission"), {
              method: 'DELETE',
              body: record
            }));

          case 1:
          case "end":
            return _context21.stop();
        }
      }
    }, _callee21);
  }));
  return _apiFieldFieldPermissionRemove.apply(this, arguments);
}

export function querySecurityGroup(_x31) {
  return _querySecurityGroup.apply(this, arguments);
}
/**
 * 角色分配安全组
 * @param {number} roleId - 角色id
 * @param {number} permissionId - 接口id
 * @param {FIELD_PERMISSION} record - 修改实体
 */

function _querySecurityGroup() {
  _querySecurityGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(params) {
    var roleId, param;
    return _regeneratorRuntime.wrap(function _callee22$(_context22) {
      while (1) {
        switch (_context22.prev = _context22.next) {
          case 0:
            roleId = params.roleId;
            param = parseParameters(params);
            return _context22.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/assigned-sec-grp"), {
              method: 'GET',
              query: _objectSpread({}, param)
            }));

          case 3:
          case "end":
            return _context22.stop();
        }
      }
    }, _callee22);
  }));
  return _querySecurityGroup.apply(this, arguments);
}

export function assignSecGrp(_x32, _x33) {
  return _assignSecGrp.apply(this, arguments);
}
/**
 * 角色取消分配安全组
 * @param {object} payload - 删除的安全组集合
 */

function _assignSecGrp() {
  _assignSecGrp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(secGrpList, roleId) {
    return _regeneratorRuntime.wrap(function _callee23$(_context23) {
      while (1) {
        switch (_context23.prev = _context23.next) {
          case 0:
            return _context23.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/assign-sec-grp"), {
              method: 'POST',
              body: secGrpList
            }));

          case 1:
          case "end":
            return _context23.stop();
        }
      }
    }, _callee23);
  }));
  return _assignSecGrp.apply(this, arguments);
}

export function deleteSecGrp(_x34) {
  return _deleteSecGrp.apply(this, arguments);
}
/**
 * 查询角色已分配的指定安全组的字段权限
 * @param {object} params - 请求参数
 */

function _deleteSecGrp() {
  _deleteSecGrp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(payload) {
    var roleId, secGrpList;
    return _regeneratorRuntime.wrap(function _callee24$(_context24) {
      while (1) {
        switch (_context24.prev = _context24.next) {
          case 0:
            roleId = payload.roleId, secGrpList = payload.secGrpList;
            return _context24.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/recycle-sec-grp"), {
              method: 'DELETE',
              body: secGrpList
            }));

          case 2:
          case "end":
            return _context24.stop();
        }
      }
    }, _callee24);
  }));
  return _deleteSecGrp.apply(this, arguments);
}

export function queryFieldPermission(_x35) {
  return _queryFieldPermission.apply(this, arguments);
}
/**
 * 查询角色已分配的指定安全组的字段权限配置
 * @param {number} params - 请求参数
 */

function _queryFieldPermission() {
  _queryFieldPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(params) {
    var roleId, secGrpId, param;
    return _regeneratorRuntime.wrap(function _callee25$(_context25) {
      while (1) {
        switch (_context25.prev = _context25.next) {
          case 0:
            roleId = params.roleId, secGrpId = params.secGrpId;
            param = parseParameters(params);
            return _context25.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/").concat(secGrpId, "/field-api"), {
              method: 'GET',
              query: _objectSpread({}, param)
            }));

          case 3:
          case "end":
            return _context25.stop();
        }
      }
    }, _callee25);
  }));
  return _queryFieldPermission.apply(this, arguments);
}

export function queryFieldConfig(_x36) {
  return _queryFieldConfig.apply(this, arguments);
}
/**
 * 查询角色已分配的指定安全组的数据权限维度
 * @param {object} params - 请求参数
 */

function _queryFieldConfig() {
  _queryFieldConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(params) {
    var roleId, secGrpId, permissionId, param;
    return _regeneratorRuntime.wrap(function _callee26$(_context26) {
      while (1) {
        switch (_context26.prev = _context26.next) {
          case 0:
            roleId = params.roleId, secGrpId = params.secGrpId, permissionId = params.permissionId;
            param = parseParameters(params);
            return _context26.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/").concat(secGrpId, "/field-api/").concat(permissionId, "/fields"), {
              method: 'GET',
              query: _objectSpread({}, param)
            }));

          case 3:
          case "end":
            return _context26.stop();
        }
      }
    }, _callee26);
  }));
  return _queryFieldConfig.apply(this, arguments);
}

export function queryDataDimension(_x37) {
  return _queryDataDimension.apply(this, arguments);
}
/**
 * 查询安全组数据权限tab页
 * @param {number} secGrpId - 安全组ID
 */

function _queryDataDimension() {
  _queryDataDimension = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(params) {
    var roleId, secGrpId, param;
    return _regeneratorRuntime.wrap(function _callee27$(_context27) {
      while (1) {
        switch (_context27.prev = _context27.next) {
          case 0:
            roleId = params.roleId, secGrpId = params.secGrpId;
            param = parseParameters(params);
            return _context27.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/").concat(secGrpId, "/dim"), {
              method: 'GET',
              query: _objectSpread({}, param)
            }));

          case 3:
          case "end":
            return _context27.stop();
        }
      }
    }, _callee27);
  }));
  return _queryDataDimension.apply(this, arguments);
}

export function queryTabList(_x38) {
  return _queryTabList.apply(this, arguments);
}
/**
 * 查询可分配的安全组
 * @param {object} params - 查询参数
 */

function _queryTabList() {
  _queryTabList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(secGrpId) {
    return _regeneratorRuntime.wrap(function _callee28$(_context28) {
      while (1) {
        switch (_context28.prev = _context28.next) {
          case 0:
            return _context28.abrupt("return", request("".concat(CPAAS_IAM, "/v1/sec-grp-dcls/").concat(secGrpId, "/dims/assigned")));

          case 1:
          case "end":
            return _context28.stop();
        }
      }
    }, _callee28);
  }));
  return _queryTabList.apply(this, arguments);
}

export function queryAssignableSecGrp(_x39) {
  return _queryAssignableSecGrp.apply(this, arguments);
}
/**
 * 查询角色已分配的指定安全组的数据权限-除公司外
 * @param {object} params - 请求参数
 */

function _queryAssignableSecGrp() {
  _queryAssignableSecGrp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(params) {
    var roleId, param;
    return _regeneratorRuntime.wrap(function _callee29$(_context29) {
      while (1) {
        switch (_context29.prev = _context29.next) {
          case 0:
            roleId = params.roleId;
            param = parseParameters(params);
            return _context29.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/assignable-sec-grp"), {
              method: 'GET',
              query: _objectSpread({}, param)
            }));

          case 3:
          case "end":
            return _context29.stop();
        }
      }
    }, _callee29);
  }));
  return _queryAssignableSecGrp.apply(this, arguments);
}

export function queryData(_x40) {
  return _queryData.apply(this, arguments);
}
/**
 * 查询角色已分配的指定安全组的数据权限-公司
 * @param {object} params - 请求参数
 */

function _queryData() {
  _queryData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(params) {
    var roleId, secGrpId, param;
    return _regeneratorRuntime.wrap(function _callee30$(_context30) {
      while (1) {
        switch (_context30.prev = _context30.next) {
          case 0:
            roleId = params.roleId, secGrpId = params.secGrpId;
            param = parseParameters(params);
            return _context30.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/").concat(secGrpId, "/dcl"), {
              method: 'GET',
              query: _objectSpread({}, param)
            }));

          case 3:
          case "end":
            return _context30.stop();
        }
      }
    }, _callee30);
  }));
  return _queryData.apply(this, arguments);
}

export function queryCompanyPermission(_x41) {
  return _queryCompanyPermission.apply(this, arguments);
}

function _queryCompanyPermission() {
  _queryCompanyPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(params) {
    var roleId, secGrpId, param;
    return _regeneratorRuntime.wrap(function _callee31$(_context31) {
      while (1) {
        switch (_context31.prev = _context31.next) {
          case 0:
            roleId = params.roleId, secGrpId = params.secGrpId;
            param = parseParameters(params);
            return _context31.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/sec-grp-user-assign/").concat(roleId, "/").concat(secGrpId, "/dcl"), {
              method: 'GET',
              query: param
            }));

          case 3:
          case "end":
            return _context31.stop();
        }
      }
    }, _callee31);
  }));
  return _queryCompanyPermission.apply(this, arguments);
}

export function queryDimension() {
  return _queryDimension.apply(this, arguments);
}

function _queryDimension() {
  _queryDimension = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
    return _regeneratorRuntime.wrap(function _callee32$(_context32) {
      while (1) {
        switch (_context32.prev = _context32.next) {
          case 0:
            return _context32.abrupt("return", request("".concat(CPAAS_IAM, "/v1/").concat(currentOrganizationId, "/doc-type/dimensions/biz"), {
              method: 'GET'
            }));

          case 1:
          case "end":
            return _context32.stop();
        }
      }
    }, _callee32);
  }));
  return _queryDimension.apply(this, arguments);
}

export function queryEmployee(_x42) {
  return _queryEmployee.apply(this, arguments);
}

function _queryEmployee() {
  _queryEmployee = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(params) {
    var parsedParams, userId, res;
    return _regeneratorRuntime.wrap(function _callee33$(_context33) {
      while (1) {
        switch (_context33.prev = _context33.next) {
          case 0:
            parsedParams = parseParameters(params);
            userId = parsedParams.userId, res = _objectWithoutProperties(parsedParams, _excluded6);
            return _context33.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(currentOrganizationId, "/users/").concat(userId, "/user-employee-assigns"), {
              query: res,
              method: 'GET'
            }));

          case 3:
          case "end":
            return _context33.stop();
        }
      }
    }, _callee33);
  }));
  return _queryEmployee.apply(this, arguments);
}